/** @file MusicController.h
 *	@class MusicController
 *  @brief The musiccontroller watches the model and makes changes in music accordingly.
 */
#include "stdafx.h"

#ifndef _MusicController_h_
#define _MusicController_h_
#include <list>
#include "PlayerAvatar.h"
#include "Model.h"
#include "Controller.h"
#include "Sound2d.h"
#include "SoundPlayer.h"
#include "fmodproj.h"
#include <math.h>
#include "Input.h"
#include "InputObserver.h"

class MusicController: public Controller, public InputObserver
{

public:
	/**
	* @brief Create a new musiccontroller
	* @param playerAvatarThe player to watch for health, shooting etc
	* @param model The model to watch
	*/
	MusicController(Model *model);
	
	/**
	* @brief destructor
	*/
	~MusicController();
	
	/**
	* @brief starts the (event-based) music
	*/
	void startMusic();
	
	/**
	* @brief stops the (event-based) music
	*/	
	void stopMusic();
	
	/**
	* @brief set the avatar to "listen to"
	*/
	void setMainAvatar(PlayerAvatar* playerAvatar);
	
	/**
	* @brief add another avatar (for tension calculations)
	*/
	void addAvatar(PlayerAvatar* playerAvatar);
	
	/**
	* @brief remove an avatar (for tension calculations)
	*/
	void removeAvatar(PlayerAvatar* playerAvatar);
	
	/**
	* @brief update the music controller
	*/
	virtual bool update(float deltaTime);
	void setEventBasedMusic(bool eventBasedMusic);

	bool keyPressed(const OIS::KeyEvent &arg);

private:
	PlayerAvatar* m_mainAvatar;
	/**
	* @brief list of the other avatars in the game
	*/
	 std::list<PlayerAvatar*>* m_avatarList;
	
	/**
	* @brief tension variables
	*/
	float m_tensionCurrent, m_tensionTarget, m_tensionMin, m_tensionMax, m_tensionChangeRate;
	
	/**
	* @brief health variables
	*/
	float m_healthCurrent, m_healthTarget, m_healthMin, m_healthMax, m_healthChangeRate;
	Sound2d* m_music;
	bool m_eventMusic;
	bool m_musicPlaying;
};


#endif // _MusicController_h_

